package com.utilities.dataStructures;

public class Range {

	private int lowerLimit = 0;
	private int upperLimit = 0;
	private boolean reverseFlag = false;
	private String metadata = null;
	private int otherData = 0;
	private double actualLength = 0.0;
	
	private Range(){}
	
	public double getActualLength() 
	{
		return actualLength;
	}

	public Range setActualLength(double actualLength) 
	{
		this.actualLength = actualLength;
		return this;
	}

	public int getOtherData() 
	{
		return otherData;
	}

	public Range (int lowerLimit, int upperLimit, String metadata)
	{
		this.lowerLimit = lowerLimit;
		this.upperLimit = upperLimit;
		this.metadata = metadata;
	}
	
	public Range (int lowerLimit, int upperLimit, boolean reverseFlag, String metadata)
	{
		this.lowerLimit = lowerLimit;
		this.upperLimit = upperLimit;
		this.reverseFlag = reverseFlag;
		this.metadata = metadata;
	}
	
	public Range (int lowerLimit, int upperLimit, String metadata, int otherData)
	{
		this.lowerLimit = lowerLimit;
		this.upperLimit = upperLimit;
		this.metadata = metadata;
		this.otherData = otherData;
	}
	
	public boolean contains(Range r)
	{
		if (lowerLimit <= r.getLowerLimit() && upperLimit > r.getUpperLimit())
			return true;
		else if (lowerLimit < r.getLowerLimit() && upperLimit >= r.getUpperLimit())
			return true;
		else 
			return false;
	}
	
	public boolean exclusive(Range r)
	{
//		if ((lowerLimit < r.getLowerLimit() && r.getLowerLimit() < upperLimit)
//				|| (lowerLimit < r.getUpperLimit() && r.getUpperLimit() < upperLimit))
//			return false;
//		else return true;
		
		
		if ((lowerLimit < r.getLowerLimit() && r.getLowerLimit() > upperLimit)
				|| (lowerLimit > r.getUpperLimit() && r.getUpperLimit() < upperLimit))
			return true;
		else return false;
	}
	
	public boolean isReverse()
	{
		return reverseFlag;
	}
	
	public int getUpperLimit()
	{
		return upperLimit;
	}
	
	public int getLowerLimit()
	{
		return lowerLimit;
	}
	
	public String getMetadata()
	{
		return metadata;
	}
	
	public void setMetadata(String metadata)
	{
		this.metadata = metadata;
	}
	
	public int length()
	{
		return upperLimit - lowerLimit + 1;
	}
}
